/*
 * (C) 2010 AXIOHELIX. All rights reserved.
 */

package com.snline.crm.logistics.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginInterceptor extends AbstractInterceptor
{
	private static final long serialVersionUID = -6027604464670201140L;
	
	@Override
	public String intercept(ActionInvocation invocation) throws Exception{
		Map<String, Object> session = ActionContext.getContext().getSession();
		
		if (session != null && session.size()>0){
		    if (session.get("userId") != null && Integer.parseInt(session.get("userId").toString())!=0) {
	            return invocation.invoke();
		    }
		}
		
		return "sessionExpired";
	}
}
